//
//  HLContactViewController.m
//  zhuanxian
//
//  Created by zhaoliang chen on 2017/11/16.
//  Copyright © 2017年 huiling. All rights reserved.
//

#import "HLContactViewController.h"
#import "UITableView+Function.h"
#import "HLContactListVC.h"

@interface HLContactViewController ()
<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)UITableView* tableViewContact;

@end

@implementation HLContactViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setNavigationTitle:@"通讯录" Color:[UIColor whiteColor]];
    
    [self.view addSubview:self.tableViewContact];
    [self.tableViewContact mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.view);
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"ContactCell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"ContactCell"];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    switch (indexPath.row) {
        case 0: {
            cell.imageView.image = [UIImage imageNamed:@"hl_contact_receiver"];
            cell.textLabel.text = @"收货人";
        }
            break;
        case 1: {
            cell.imageView.image = [UIImage imageNamed:@"hl_contact_sender"];
            cell.textLabel.text = @"发货人";
        }
            break;
        case 2: {
            cell.imageView.image = [UIImage imageNamed:@"hl_contact_driver"];
            cell.textLabel.text = @"司机";
        }
            break;
        case 3: {
            cell.imageView.image = [UIImage imageNamed:@"hl_contact_branch"];
            cell.textLabel.text = @"网点";
        }
            break;
        default:
            break;
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 60;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    //[SVProgressHUD showInfoWithStatus:@"等待更新"];
    switch (indexPath.row) {
        case 0: {
            HLContactListVC* vc = [[HLContactListVC alloc]initWithType:receiver];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1: {
            HLContactListVC* vc = [[HLContactListVC alloc]initWithType:sender];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        default:
            break;
    }
}

- (UITableView*)tableViewContact {
    if (!_tableViewContact) {
        _tableViewContact = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableViewContact.dataSource = self;
        _tableViewContact.delegate = self;
        _tableViewContact.separatorInset = UIEdgeInsetsZero;
        _tableViewContact.hideExtraCell = YES;
    }
    return _tableViewContact;
}

@end
